package edu.hawaii.myisern.action;

import java.util.Set;
import java.util.Map.Entry;
import javax.xml.bind.JAXBException;
import org.xml.sax.SAXException;
import edu.hawaii.myisern.model.MyIsernModel;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

/**
 * @author Shaoxuan Zhang
 *
 */
public class SanityCheckActionBean extends MyIsernActionBean {
  /** MyIsern instance manipulated by all webapp users. */
  private MyIsernModel myIsern = MyIsernModel.getInstance();

  /**
   * Constructor
   * 
   * @throws JAXBException when JAXB fails.
   * @throws SAXException when SAX fails.
   */
  public SanityCheckActionBean () throws JAXBException, SAXException {
    // empty constructor
  }
  
  /**
   * Return a list of Researcher that is missing.
   * @return a Set of String
   */
  public Set<String> getMissingResearcher() {
    return this.myIsern.getMissingResearcher();
    
  }
  
  /**
   * Return a list of Organization that is missing.
   * @return a Set of String
   */
  public Set<String> getMissingOrganization() {
    return this.myIsern.getMissingOrganization();
    
  }
  
  /**
   * Return a list of violations within researchers.
   * @return a List of Map Entry.
   */
  public Set<Entry<String, String>> getResearcherViolations() {
    return this.myIsern.getResearcherViolations();
  }

  /**
   * Return a list of violations within Collaborations.
   * @return a List of Map Entry.
   */
  public Set<Entry<String, String>> getCollaborationViolations() {
    return this.myIsern.getCollaborationViolations();
  }
  
  /**
   * Return a list of violations within Organizations.
   * @return a List of Map Entry.
   */
  public Set<Entry<String, String>> getOrganizationViolations() {
    return this.myIsern.getOrganizationViolations();
  }
  
  
  /**
   * Forwards the user to the sanityCheck.jsp page to view all errors.
   * 
   * @return A Resolution indicating to redisplay the sanityCheck.jsp page.
   */
  @DefaultHandler
  public Resolution listErrors() {
    return new ForwardResolution("/sanityCheck.jsp");
  }
}
